package com.laysonx.data.police.util;

import com.laysonx.data.police.exception.DataVerifyRuleException;
import org.springframework.util.StringUtils;

import static com.laysonx.data.police.constant.Constant.POINTCUT_NOT_ALLOW_NULL_ERROR;
import static com.laysonx.data.police.constant.Constant.SCAN_PACKAGES_NOT_ALLOW_NULL_ERROR;

/**
 * 检查工具
 * @author: Laysonx
 * @date: 2019/10/17 16:48
 */
public class CheckUtil {

    /**
     * 检查初始化所需参数
     * @author: Laysonx
     * @date: 2019/10/17 16:49
     * @param scanHelperPackages
     * @param pointcut
     * @return: void
     */
    public static void checkInitParams(String[] scanHelperPackages,String pointcut){

        // TODO 使用手动配置时 不开启校验
        if (scanHelperPackages == null || scanHelperPackages.length == 0) {
            throw new DataVerifyRuleException(SCAN_PACKAGES_NOT_ALLOW_NULL_ERROR);
        }
        if (StringUtils.isEmpty(pointcut)) {
            throw new DataVerifyRuleException(POINTCUT_NOT_ALLOW_NULL_ERROR);
        }

    }
}
